package org.syncsoft.overalt.domain.common.entity.api;

import java.util.Comparator;

import org.syncsoft.overalt.domain.common.entity.IEntity;

/**
 * 
 * @author tptfc
 *
 */
public class EntityComparator implements Comparator<IEntity> {

	@Override
	public int compare(IEntity e1, IEntity e2) {
		int result = 0;
		
		if (e1 != null && e2 != null) {
			Integer code1 = e1.getCode();
			Integer code2 = e2.getCode();
			
			result = code1.compareTo(code2);
		} else if (e1 == null) {
			result = -1;
		} else {
			result = 1;
		}
		
		return result;
	}

}
